package com.itheima;

public class StringTest {
    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "abc";
        System.out.println(s1==s2);//true
        String s3 = "abc";
        String s4 = new String("abc");
        System.out.println(s3 == s4); //false
        /*
        1变量+常量  //存在堆空间,可以理解为一次new
        2变量+常量//存在堆空间,可以理解为一次new
        3常量+常量存在常量优化机制,jvm会在编译时完成拼接
         */
        String s5 = "ab";
        String s6 = s5+"c";
        String s7 = "abc";
        System.out.println(s7 == s6);//false
        String s8 ="c";
        String s9 = s5+s8;
        System.out.println(s7 == s9);//false
        System.out.println(s6 == s9);//false
        String s10 = "a"+ "b"+ "c";
        System.out.println(s7==s10);//true

    }
}
